/**
 * Created by WEN on 2016/9/30.
 */
public class MinDepthOfBT {
    public int minDepth(TreeNode root) {
        int left,right;
        if(root==null){
            return 0;
        }else{
            left = minDepth(root.left);
            right = minDepth(root.right);
            if(right==0) return 1+left;
            else if(left == 0) return 1+right;
            else if(left>right) return 1+right;
            else return 1+left;
        }
    }
}
